﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Winformpro1
{
  
    public partial class Form1 : Form
    {       double[]c=new double[100];
        int i = 0;
        public Form1()
        {
            InitializeComponent();
            this.x.Focus();            
        }


        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

            double a = double.Parse(x.Text);
            
            if (i == 0)
            {
                sum.Text = min.Text = max.Text = ave.Text = a.ToString();
            }
            else
            {
                double temp;
                temp = double.Parse(sum.Text);
                sum.Text =(temp+ a).ToString();
                temp = double.Parse(ave.Text);
                ave.Text = ((double.Parse(ave.Text) * i + a) / (i + 1)).ToString();
                max.Text = a > double.Parse(max.Text) ? a.ToString() : max.Text;
                min.Text = a > double.Parse(min.Text) ? min.Text : a.ToString();
            }
            c[i++] = a; 
            num1.Text += a.ToString()+" ";
            x.Text = null;
        }
private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
        
        private void num1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        

        private void ave_TextChanged(object sender, EventArgs e)
        {

        }

        private void max_TextChanged(object sender, EventArgs e)
        {

        }

        private void min_TextChanged(object sender, EventArgs e)
        {

        }

        private void sum_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)//如果输入的是回车键
            {
                button1_Click(sender, e);//触发button事件
            }
        }
    }
}
